package com.cy.sys.controller;

import com.cy.sys.common.pojo.JsonResult;
import com.cy.sys.common.until.PageUtil;
import com.cy.sys.pojo.Classify;
import com.cy.sys.service.ClassifyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/classify/")
@CrossOrigin
public class ClassifyController {
    @Autowired
    private ClassifyService classifyService;

    @GetMapping
    @ApiOperation(value = "查询所有分类", notes = "无参数接收")
    public JsonResult doFindAll(){
        return new JsonResult(1,"findAll ok",
            classifyService.findAll()
        );
    }

    @GetMapping("{id}")
    @ApiOperation(value = "通过id查询分类", notes = "接收分类id")
    public JsonResult doFindById(@PathVariable Integer id){
        return new JsonResult(1,"find ok",classifyService.findById(id));
    }

    @PostMapping
    @ApiOperation(value = "新增分类", notes = "接收新增分类信息")
    public JsonResult doSaveClassify(@RequestBody Classify entity){
        classifyService.saveClassify(entity);
        return new JsonResult(1,"save ok");
    }
}
